package com.xyht.sca_s.student_manage_system.modules.repairCheck.config;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xyht.sca_s.student_manage_system.modules.repairCheck.entity.SmsRepairCheckProcess;
import com.xyht.sca_s.student_manage_system.modules.repairCheck.mapper.SmsRepairCheckProcessMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class RepairCheckApplicationInit {
    @Autowired
    private SmsRepairCheckProcessMapper smsRepairCheckProcessMapper;

    private String[] departmentNameArray = {"后勤处","检修人","报修人"};

    @Bean
    public void repairApplicationInit() {
        List<SmsRepairCheckProcess> processList =
                smsRepairCheckProcessMapper.selectList(new QueryWrapper<>());
        if (processList == null || processList.size() < 1) {
            int sort = 1;
            for (String departmentName : departmentNameArray) {
                SmsRepairCheckProcess addProcess =
                        new SmsRepairCheckProcess();
                addProcess.setProcessName(departmentName);
                addProcess.setProcessIsUse(true);
                addProcess.setProcessIsStamp(false);
                addProcess.setProcessIsSign(true);
                addProcess.setProcessIsApplicationEdit(false);
                addProcess.setProcessSort(sort++);
                smsRepairCheckProcessMapper.insert(addProcess);
            }


        }
    }


}
